<?php
class TwitterTaskFormDecorator extends ATaskFormDecorator{
    public function getFormHTML($params, $view) {
        return $this->task_form->getFormHTML($params, $view).$view->getCustomer_formbody_step2_twitter($params);
    }

    public function validate_form(&$param, &$scope, $manager) {
        $iserror = false;
        //FOLLOWERS
        if (empty($param['followers'])) {
            $iserror = true;
            $manager->addErorrMessageForField("followers", "Укажите число подписчиков");
        } elseif (intval($param['followers']) < 0) {
            $iserror = true;
            $manager->addErorrMessageForField("followers", "Отрицательное значение недопустимо");
        }
        else
            $param['followers'] = intval($param['followers']);
        //TWEETS
        if (empty($param['tweets'])) {
            $iserror = true;
            $manager->addErorrMessageForField("tweets", "Укажите число подписчиков");
        } elseif (intval($param['tweets']) < 0) {
            $iserror = true;
            $manager->addErorrMessageForField("tweets", "Отрицательное значение недопустимо");
        }
        else
            $param['tweets'] = intval($param['tweets']);

           if ($iserror) {
            return array_merge(array(VALIDATION_FAILED), $this->task_form->validate_form($param, $scope, $manager));
        }
        return array_merge(array(VALIDATION_ACCEPTED), $this->task_form->validate_form($param, $scope, $manager));
    }

    public function submit_form($params, $scope, $manager) {
        $this->task_form->submit_form($params, $scope, $manager);       
    }
}

?>
